package cn.edu.buu.hospital.entity;
import java.io.Serializable;
import java.time.LocalDateTime;
/**
 * 预约记录实体类
 */
public class Appointment implements Serializable {
    // 预约ID（主键）
    private Long appointmentid;
    // 患者用户ID（外键，关联user表type=1的用户）
    private Long userid;
    // 排班ID（外键）
    private Long visitid;
    // 预约编号
    private String number;
    // 预约状态：0-待就诊，1-已完成，2-已取消
    private Integer status;
    // 创建时间
    private LocalDateTime createtime;
    // 创建时间字符串（兼容字段）
    private String createTime;

    // 添加患者姓名字段
    private String patientName;
    
    // 添加患者电话字段
    private String patientPhone;
    
    // 添加症状描述字段
    private String symptoms;
    
    // 添加Visit对象引用
    private Visit visit;

    // 无参构造方法
    public Appointment() {
    }
    // 全参构造方法
    public Appointment(Long appointmentid, Long userid, Long visitid, String number, Integer status, LocalDateTime createtime) {
        this.appointmentid = appointmentid;
        this.userid = userid;
        this.visitid = visitid;
        this.number = number;
        this.status = status;
        this.createtime = createtime;
    }
    // getter和setter方法
    public Long getAppointmentid() {
        return appointmentid;
    }

    public Long getUserid() {
        return userid;
    }

    public void setUserid(Long userid) {
        this.userid = userid;
    }

    public Long getVisitid() {
        return visitid;
    }

    public void setVisitid(Long visitid) {
        this.visitid = visitid;
    }

    public String getNumber() {
        return number;
    }

    public void setNumber(String number) {
        this.number = number;
    }

    public Integer getStatus() {
        return status;
    }

    public void setStatus(Integer status) {
        this.status = status;
    }

    public LocalDateTime getCreatetime() {
        return createtime;
    }

    public void setCreatetime(LocalDateTime createtime) {
        this.createtime = createtime;
    }
    // 添加createTime的getter方法以兼容JSP页面中的使用
    public LocalDateTime getCreateTime() {
        return this.getCreatetime();
    }
    
    public void setCreateTime(String createTime) {
        this.createTime = createTime;
    }
    
    // 格式化时间为字符串，供JSP页面使用
    public String getCreateTimeString() {
        if (createTime != null) {
            return createTime;
        } else if (createtime != null) {
            // 如果createTime为null但createtime有值，格式化LocalDateTime
            return createtime.toString();
        }
        return null;
    }
    public String getPatientName() {
        return patientName;
    }
    public void setPatientName(String patientName) {
        this.patientName = patientName;
    }
    
    public String getPatientPhone() {
        return patientPhone;
    }
    
    public void setPatientPhone(String patientPhone) {
        this.patientPhone = patientPhone;
    }
    
    public String getSymptoms() {
        return symptoms;
    }
    
    public void setSymptoms(String symptoms) {
        this.symptoms = symptoms;
    }
    
    public Visit getVisit() {
        return visit;
    }
    public void setVisit(Visit visit) {
        this.visit = visit;
    }
    // toString方法
    @Override
    public String toString() {
        return "Appointment{" +
                "appointmentid=" + appointmentid +
                ", userid=" + userid +
                ", visitid=" + visitid +
                ", number='" + number + '\'' +
                ", status=" + status +
                ", createtime=" + createtime +
                ", patientName='" + patientName + '\'' +
                ", visit=" + visit +
                '}';
    }
    public Long getAppointmentId() {
        return this.getAppointmentid();
    }
    // 添加兼容visitId的setter方法，以便Spring MVC可以正确绑定表单参数
    public void setVisitId(Long visitId) {
        this.setVisitid(visitId);
    }
    
    public Long getVisitId() {
        return this.getVisitid();
    }
    
    public void setUserId(Long userId) {
        this.setUserid(userId);
    }
    
    public Long getUserId() {
        return this.getUserid();
    }
}